import Vue from 'vue'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets
import 'font-awesome/scss/font-awesome.scss' // font-awesome基础样式
import Element from 'element-ui'
import '@/assets/styles/element-variables.scss'
import '@/assets/styles/index.scss' // global css
//import 'element-ui/lib/theme-chalk/index.css'
import VueI18n from 'vue-i18n'
import { messages } from '@/i18n/i18n'

// 全局弹窗点击modal不关闭
Element.Dialog.props.closeOnClickModal.default = false

import Cookies from 'js-cookie'

import App from './App'
import store from './store'
import router from './router'

import '@/assets/icons' // icon
import '@/permission' // permission control
import '@/utils/error-log' // error log
import '@/utils/index'

// 全局组件挂载
import ArrowUp from '@/components/ArrowUp'
import Sticky from '@/components/Sticky'
import FileViewer from '@/components/FileViewer'
import TableToolbar from '@/components/TableToolbar'
import Pagination from '@/components/Pagination'
import PanThumb from '@/components/PanThumb'
import ImageCropper from '@/components/ImageCropper'
import ImgReview from '@/components/ImgReview'
import TinymceEditor from '@/components/Tinymce'
import MarkdownEditor from '@/components/Markdown'
Vue.component('ArrowUp', ArrowUp)
Vue.component('Sticky', Sticky)
Vue.component('FileViewer', FileViewer)
Vue.component('TableToolbar', TableToolbar)
Vue.component('Pagination', Pagination)
Vue.component('PanThumb', PanThumb)
Vue.component('ImageCropper', ImageCropper)
Vue.component('ImgReview', ImgReview)
Vue.component('TinymceEditor', TinymceEditor)
Vue.component('MarkdownEditor', MarkdownEditor)

import $ from 'jquery'
import uploader from 'vue-simple-uploader'
Vue.use(uploader)

import JsonSchemaEditor from 'json-schema-editor-vue'
Vue.use(JsonSchemaEditor)

import CodeEditor from 'bin-code-editor'
Vue.use(CodeEditor)

import VueHtmlToPaper from 'vue-html-to-paper'
Vue.use(VueHtmlToPaper)

import Chat from 'vue-beautiful-chat'
Vue.use(Chat)

import * as filters from './filters' // global filters
for (let i in filters) {
  Vue.filter(i, filters[i])
}

import directive from './directive'
import plugins from './plugins'
Vue.use(directive)
Vue.use(plugins)

import request from '@/utils/request'
Vue.prototype.$http = request

import { copyright, getConfig, getDictGroup } from '@/api/system/route'
Vue.prototype.$copyright = copyright
Vue.prototype.$config = getConfig
Vue.prototype.$dictGroup = getDictGroup

import * as api from '@/utils'
Vue.prototype.$api = api

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'development') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

Vue.use(VueI18n)
Vue.use(Element, {
  size: Cookies.get('element-size') || 'small' // set element-ui default size
})

const i18n = new VueI18n({
  locale: 'zh',
  messages
})

// register global utility filters
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  i18n,
  store,
  $,
  render: h => h(App)
})
